
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"

struct NM{
    int p;
    int cnt;
};
class Solution {
public:
    int cheapest(std::vector<NM>& vec){
        int ret=0;
        while(vec[ret].cnt==0){
            ret++;
        }
        for(int i=1;i<vec.size();i++){
            if(vec[i].cnt>0&&vec[i].p<vec[ret].p){
                ret=i;
            }
        }
        return ret;
    }
    void run() {

        bool first = true;

        int a,b;
        while (std::cin>>a>>b) {
            std::vector<NM> vec;
            int pay=0;
            for(int i=0;i<b;i++){
                NM nm;
                std::cin>>nm.p>>nm.cnt;
                vec.push_back(nm);
            }
            int left=a;
            while(left){
                auto cheap= cheapest(vec);
                if(vec[cheap].cnt>=left){
                    pay+=left*vec[cheap].p;
                    vec[cheap].cnt-=left;
                    left=0;
                }else{
                    pay+=vec[cheap].cnt*vec[cheap].p;
                    left-=vec[cheap].cnt;
                    vec[cheap].cnt=0;
                }
            }
            printf("%d\n",pay);
        }
    }
};

int main() {
//    bool cur_num= true;
    Solution().run();
    return 0;
}

